package org.jeecg.modules.api.service;

import com.google.gson.JsonObject;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.modules.api.SynchVo;
import org.jeecgframework.p3.core.util.MD5Util;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class PaperService {
    private  final  String  url = "https://preview.suzhou-news.cn/news/syncAdd";

    public  String synch(SynchVo synchVo) {
        JsonObject jsonObject = new JsonObject();

        jsonObject.addProperty("sys_documentid",synchVo.getId());
        String token = MD5Util.MD5Encode(synchVo.getId()+"E_YLB","utf-8").toLowerCase();
        jsonObject.addProperty("token", token);
        jsonObject.addProperty("sys_topic",synchVo.getTitle());
        jsonObject.addProperty("sys_authors",synchVo.getAuthor());
        jsonObject.addProperty("doc_content",synchVo.getContent());
        jsonObject.addProperty("sys_authors",synchVo.getAuthor());

        String result = null;
        try{
            log.info(jsonObject.toString());

            result =   com.xinke.common.util.HttpClientUtil.sendPostDataByJson(url,jsonObject.toString(),"utf-8");

          }catch (Exception e) {
            log.info(e.getMessage());

        }
        log.info(result);
        return  result;

    }


    public static void main(String[] args) {
        System.out.println(         MD5Util.MD5Encode("E_YLBfounder","utf-8").toLowerCase());

    }
}
